#!/bin/sh -e
#
# Build the entire project using the autogen.sh, configure, make, make install
#
# Use these script at your own risk!
# These are generally for Unix platforms.
# Start this script from the source directory.
#
# License:
#      Zipios -- a small C++ library that provides easy access to .zip files.
#
#      Copyright (C) 2015-2019  Made to Order Software Corporation
#
#      This library is free software; you can redistribute it and/or
#      modify it under the terms of the GNU Lesser General Public
#      License as published by the Free Software Foundation; either
#      version 2.1 of the License, or (at your option) any later version.
#
#      This library is distributed in the hope that it will be useful,
#      but WITHOUT ANY WARRANTY; without even the implied warranty of
#      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
#      Lesser General Public License for more details.
#
#      You should have received a copy of the GNU Lesser General Public
#      License along with this library; if not, write to the Free Software
#      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
#

SOURCE_PATH=`pwd`

# Create output directory
cd ..
rm -rf BUILD
mkdir -p BUILD/dist BUILD/zipios

# Run cmake
cd BUILD
BUILD_PATH=`pwd`
cd zipios
if test "$1" = "-d"
then
    # Include debug here
    cmake -DCMAKE_INSTALL_PREFIX:PATH=$BUILD_PATH/dist \
          -DCMAKE_BUILD_TYPE=Debug \
                ../../zipios
else
    cmake -DCMAKE_INSTALL_PREFIX:PATH=$BUILD_PATH/dist \
                ../../zipios
fi

# Build
make

# Install
make install

# Run tests
cd $SOURCE_PATH/tests
../../BUILD/zipios/tests/zipios_tests


# vim: ts=4 sw=4 et et
